#include <bits/stdc++.h>
using namespace std;

struct Cor {
	int x;
	int y;
};
Cor diff[5] = {{0,0}, {0,1}, {0,-1}, {1,0}, {-1,0}};

const int maxn = 1010;
char a[maxn][maxn];
int c[maxn][maxn];
int main() {
	int n,m;
	cin >> n >> m; 
	for (int i=1; i<=n; i++) {
		cin >> a[i] + 1;
	}
	
	int sum = 0;
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {			
			int cnt = 0;
			int cur_k = -1;
			for (int k=0; k<5; k++) {
				int x = i+diff[k].x;
				int y = j+diff[k].y;
				if (x>=1 && x<=n && y>=1 && y<=m) {
					if (a[x][y] == '#') {
						cnt ++;
						cur_k = k;
					}
				}
			}
			if (cnt == 0) {
				sum ++;
			} else if (cnt == 1) {
				int x = i+diff[cur_k].x;
				int y = j+diff[cur_k].y;
				c[x][y] += 1;
			}
		}
	}
	int max_s = sum;
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			max_s = max(max_s, sum + c[i][j]);
		}
	}
	cout << max_s << endl;
	return 0;
}
